<template>
  <a-modal
    title="新建指标"
    :visible="visible"
    :confirm-loading="confirmLoading"
    @ok="handleSubmit"
    @cancel="handleCancel"
    :width="width"
    :class="{ myFullScreen: fullScreen }"
    :zIndex="99999"
  >
    <a-form-model ref="form" :model="model" :rules="validatorRules">
      <a-row>
        <a-col :span="12">
          <a-form-model-item label="指标代码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zbdm">
            <a-input v-model="model.zbdm" placeholder="请输入指标代码"></a-input>
          </a-form-model-item>
        </a-col>
        <a-col :span="12">
          <a-form-model-item label="指标名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zbmc">
            <a-input v-model="model.zbmc" placeholder="请输入指标名称"></a-input>
          </a-form-model-item>
        </a-col>
        <a-col :span="12">
          <a-form-model-item label="数值类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bslx">
            <j-tree-select
              ref="treeSelect"
              placeholder="请选择数值类型"
              v-model="model.bslx"
              dict="rspc_param_config,name,code"
              pidValue="11170783058900"
              hasChildField="has_child"
            >
            </j-tree-select>
          </a-form-model-item>
        </a-col>
        <a-col :span="12">
          <a-form-model-item label="币种类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bzlx">
            <j-tree-select
              ref="treeSelect"
              placeholder="请选择币种类型"
              v-model="model.bzlx"
              dict="rspc_bz_config,name,code"
              pidValue="1382973175608823809"
              hasChildField="has_child"
            >
            </j-tree-select>
          </a-form-model-item>
        </a-col>
        <a-col :span="12">
          <a-form-model-item label="币种单位" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bzdw">
            <j-tree-select
              ref="treeSelect"
              placeholder="请选择币种单位"
              v-model="model.bzdw"
              dict="rspc_param_config,name,code"
              pidValue="2B290F72BF7E4B39B2D56F1934D5F43F"
              hasChildField="has_child"
            >
            </j-tree-select>
          </a-form-model-item>
        </a-col>
        <a-col :span="12">
          <a-form-model-item label="数据属性" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sjsx">
            <j-tree-select
              ref="treeSelect"
              placeholder="请选择数据属性"
              v-model="model.sjsx"
              dict="rspc_param_config,name,code"
              pidValue="11311376545200"
              hasChildField="has_child"
            >
            </j-tree-select>
          </a-form-model-item>
        </a-col>
        <a-col :span="12">
          <a-form-model-item label="是否汇总" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sfhz">
            <j-tree-select
              ref="treeSelect"
              placeholder="请选择是否汇总"
              v-model="model.sfhz"
              dict="rspc_param_config,name,code"
              pidValue="1486500350999949313"
              hasChildField="has_child"
            >
            </j-tree-select>
          </a-form-model-item>
        </a-col>
        <a-col :span="12">
          <a-form-model-item label="是否叶子" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sfyz">
            <j-tree-select
              ref="treeSelect"
              placeholder="请选择是否叶子"
              v-model="model.sfyz"
              dict="rspc_param_config,name,code"
              pidValue="1486500350999949313"
              hasChildField="has_child"
            >
            </j-tree-select>
          </a-form-model-item>
        </a-col>
        <a-col :span="12">
          <a-form-model-item label="机构汇总" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="yzhz">
            <j-tree-select
              ref="treeSelect"
              placeholder="请选择机构汇总"
              v-model="model.yzhz"
              dict="rspc_param_config,name,code"
              pidValue="1486500350999949313"
              hasChildField="has_child"
            >
            </j-tree-select>
          </a-form-model-item>
        </a-col>
        <a-col :span="12">
          <a-form-model-item label="生效日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="startrq">
            <j-date placeholder="请选择生效日期" v-model="model.startrq" style="width: 100%" />
          </a-form-model-item>
        </a-col>
        <a-col :span="12">
          <a-form-model-item label="失效日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="endrq">
            <j-date placeholder="请选择失效日期" v-model="model.endrq" style="width: 100%" />
          </a-form-model-item>
        </a-col>
        <a-col :span="12">
          <a-form-model-item label="指标描述" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zbms">
            <a-input v-model="model.zbms" placeholder="请输入指标描述"></a-input>
          </a-form-model-item>
        </a-col>
        <a-col :span="12">
          <a-form-model-item label="是否公式" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sfgs">
            <j-tree-select
              ref="treeSelect"
              placeholder="请选择是否公式"
              v-model="model.sfgs"
              dict="rspc_param_config,name,code"
              pidValue="1486500350999949313"
              hasChildField="has_child"
            >
            </j-tree-select>
          </a-form-model-item>
        </a-col>
        <a-col :span="12">
          <a-form-model-item label="有无数据" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ywsj">
            <j-tree-select
              ref="treeSelect"
              placeholder="请选择有无数据"
              v-model="model.ywsj"
              dict="rspc_param_config,name,code"
              pidValue="cacc7bb2010147b389320e50db62b22f"
              hasChildField="has_child"
            >
            </j-tree-select>
          </a-form-model-item>
        </a-col>
        <a-col :span="12">
          <a-form-model-item label="是否有效" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sfyx">
            <j-tree-select
              ref="treeSelect"
              placeholder="请选择是否有效"
              v-model="model.sfyx"
              dict="rspc_param_config,name,code"
              pidValue="cacc7bb2010147b389320e50db62b22f"
              hasChildField="has_child"
            >
            </j-tree-select>
          </a-form-model-item>
        </a-col>
      </a-row>
    </a-form-model>
  </a-modal>
</template>

<script>
import FullScreenTitle from './FullScreenTitle'
import { getMetaList } from '@/api/websheet'

export default {
  name: 'RspcReportItemModal',
  components: { FullScreenTitle },
  props: {
    //表单禁用
    disabled: {
      type: Boolean,
      default: false,
      required: false,
    },
    visible: {
      type: Boolean,
      default: false,
      required: false,
    },
    confirmLoading: {
      type: Boolean,
      default: false,
      required: false,
    },
    bbdm: {
      type: String,
      default: false,
      required: false,
    },
  },
  data() {
    return {
      model: {},
      labelCol: {
        xs: { span: 24 },
        sm: { span: 6 },
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 },
      },
      validatorRules: {
        // bbdm: [{ required: true, message: '请输入报表代码!' }],
        zbdm: [{ required: true, message: '请输入指标代码!' }],
        zbmc: [{ required: true, message: '请输入指标名称!' }],
        bslx: [{ required: true, message: '请输入数值类型!' }],
        bzlx: [{ required: true, message: '请选择币种类型!' }],
        bzdw: [{ required: true, message: '请选择币种单位!' }],
        sjsx: [{ required: true, message: '请输入数据属性!' }],
        sfhz: [{ required: true, message: '请选择是否汇总!' }],
        sfyz: [{ required: true, message: '请选择是否叶子!' }],
        yzhz: [{ required: true, message: '请输入机构汇总!' }],
        startrq: [{ required: true, message: '请选择生效日期!' }],
        endrq: [{ required: true, message: '请选择失效日期!' }],
        zbms: [{ required: true, message: '请输入指标描述!' }],
        sfgs: [{ required: true, message: '请选择是否公式!' }],
        ywsj: [{ required: true, message: '请选择有无数据!' }],
        sfyx: [{ required: true, message: '请选择是否有效!' }],
      },
      width: 1000,
      fullScreen: false,
      metaList: [],
    }
  },
  created() {
    getMetaList({ pageSize: 1000, bbfl: '1' }).then((res) => {
      if (res.code === 200) {
        this.metaList = res.result.records || []
      } else {
        this.$message.warning('服务器出错!')
      }
    })
  },
  mounted() {},
  // watch: {
  //   detail(newValue, oldValue) {
  //     if (newValue.reportTabName) {
  //       this.queryTypeAuth(newValue.reportTabName)
  //       this.initReportList2(newValue.reportTabName)
  //     }
  //   },
  // },
  methods: {
    fullScreenTitle() {
      return (
        <full-screen-title
          title="分区分类配置"
          fullCoderEdit={this.fullCoderEdit}
          fullScreen={this.fullScreen}
        ></full-screen-title>
      )
    },
    fullCoderEdit() {
      this.width = this.fullScreen ? 1000 : '100%'
      this.fullScreen = !this.fullScreen
    },
    queryTypeAuth(reportCode) {
      getTypeAuth({ reportCode }).then((res) => {
        if (res.code === 200) {
          this.form = res.result || {}
        } else {
          this.$message.warning('服务器出错')
        }
      })
    },
    handleSubmit() {
      this.$refs.form.validate((valid) => {
        if (valid) {
          this.$emit('ok', { ...this.model, bbdm: this.bbdm })
          console.log('%c [ this.form ]-313', 'font-size:13px; background:pink; color:#bf2c9f;', this.model)
        } else {
          return false
        }
      })
    },
    handleCancel() {
      this.fullScreen = false
      this.width = 1000
      this.$emit('cancel')
    },
  },
}
</script>
<style lang="less" scoped>
.myHeadBtn {
  line-height: 24px;
  .myHeadBtnTip {
    margin-left: 15px;
    color: #1890ff;
    font-size: 14px;
  }
}
</style>